package com.zhz.system.repository.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhz.common.tool.mybatisplus.base.dal.entity.BasePO;
import com.zhz.common.tool.mybatisplus.base.dal.repository.impl.BaseRepositoryImpl;
import com.zhz.model.system.Role;
import com.zhz.model.system.contract.dto.RoleDTO;
import com.zhz.model.system.contract.param.RoleQueryParam;
import com.zhz.system.repository.dao.RoleDao;
import com.zhz.system.repository.service.RoleService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 角色服务实现
 *
 * @author zhouhengzhe
 * @date 2023/3/30
 */
@Service
public class RoleServiceImpl extends BaseRepositoryImpl<RoleDao, RoleDTO, Role, RoleQueryParam> implements RoleService {
    @Override
    protected QueryWrapper<Role> getWrapper(RoleQueryParam queryParam) {
        return new QueryWrapper<Role>()
                .eq(StringUtils.isNotBlank(queryParam.getId()), BasePO.ID, queryParam.getId())
                .in(CollectionUtils.isNotEmpty(queryParam.getIds()), BasePO.ID, queryParam.getIds())
                .eq(StringUtils.isNotBlank(queryParam.getName()), Role.NAME, queryParam.getName())
                .eq(StringUtils.isNotBlank(queryParam.getCompanyId()), Role.COMPANY_ID, queryParam.getCompanyId());
    }
}
